home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_bas / pbc32.zip / PBC$BAS.ZIP / PATCH.BAS < prev    next >
BASIC Source File  |  1996-04-10  |  2KB  |  52 lines

  1. '   +----------------------------------------------------------------------+
  2. '   |                                                                      |
  3. '   |   PBClone  (C) Copyright 1996 Charon Software, All Rights Reserved   |
  4. '   |                                                                      |
  5. '   +----------------------------------------------------------------------+
  6.  
  7.    DECLARE SUB FClose1 (BYVAL FileHandle%)
  8.    DECLARE SUB FOpen1 (FileName$, BYVAL ReadWrite%, BYVAL Sharing%, FileHandle%, ErrCode%)
  9.    DECLARE SUB FSetOfs (BYVAL FileHandle%, Offset&)
  10.    DECLARE SUB SFRead (BYVAL FileHandle%, St$, BytesRead%, ErrCode%)
  11.    DECLARE SUB SFWrite (BYVAL FileHandle%, St$, BytesWritten%, ErrCode%)
  12.  
  13.    DECLARE FUNCTION Patch01% ()
  14.    DECLARE SUB Patch00 (BYVAL FileHandle%)
  15.  
  16. SUB FindPatch (FileName$, SearchSt$, ErrCode%)
  17.    IF INSTR(FileName$, ".") THEN
  18.       File$ = FileName$
  19.    ELSE
  20.       File$ = FileName$ + ".EXE"
  21.    END IF
  22.    FOpen1 File$, 2, 2, Handle%, ErrCode%
  23.    Chunk$ = SPACE$(512)
  24.    DO UNTIL Found% OR ErrCode%
  25.       SFRead Handle%, Chunk$, BytesRead%, ErrCode%
  26.       St$ = RIGHT$(St$ + LEFT$(Chunk$, BytesRead%), 768)
  27.       IF ErrCode% <= 0 THEN
  28.          tmp% = INSTR(St$, SearchSt$)
  29.          IF tmp% THEN
  30.             Found% = -1
  31.             FSetOfs Handle%, CLNG(tmp% + LEN(SearchSt$) + 5 - LEN(St$))
  32.             Patch00 Handle%
  33.          END IF
  34.       END IF
  35.    LOOP
  36.    IF ErrCode% <= 0 THEN ErrCode% = NOT Found%
  37. END SUB
  38.  
  39.  
  40.  
  41. SUB PatchDone
  42.    FClose1 Patch01%
  43. END SUB
  44.  
  45.  
  46.  
  47. SUB SetPatch (St$)
  48.    Handle% = Patch01%
  49.    SFWrite Handle%, St$, BytesWritten%, ErrCode%
  50.    FSetOfs Handle%, 6&
  51. END SUB
  52.